package com.ziyun.pop.mall.module.user.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.service.common.model.PageParamDto;
import com.service.common.model.PageResult;
import com.service.ucenter.api.UserWalletService;
import com.service.ucenter.model.wallet.ScholarshipRecordVO;
import com.service.utils.push.umeng.JsonResult;
import com.ziyun.pop.mall.system.config.HttpRequestLocal;

/**
 * 用户奖学金Controller
 *
 * @author lvai 11.12
 */
@Controller
public class UserScholarshipController {
	private static Logger _log = LoggerFactory.getLogger(UserScholarshipController.class);
	private static final String MODEL = "/user/userScholarship";
	@Autowired
	private UserWalletService userWalletService;
	
	@Autowired
	private HttpRequestLocal httpRequestLocal;

	@GetMapping(MODEL + "/index.do")
	@ResponseBody
	public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("/user/userScholarship/index.html");
		return view;
	}

	/**
	 * 获取用户奖励金记录
	 * 
	 * @return
	 */
	@PostMapping(MODEL + "/listScholarshipRecord.json")
	@ResponseBody
	public JsonResult<Map<String, Object>> listScholarshipRecord(PageParamDto pageParamDto) {
		Map<String, Object> map = new HashMap<String, Object>();
		Long userId = (Long) httpRequestLocal.getSessionValue("userId");
		PageResult<ScholarshipRecordVO> scholarshipRecordVOPage = userWalletService.listScholarshipRecord(userId,pageParamDto)
				.getData();
		map.put("scholarshipRecordVOPage", scholarshipRecordVOPage);
		return JsonResult.success(map);
	}

}
